package exttable.formgenerator;

import java.util.Comparator;

/**
 * Created by IntelliJ IDEA.
 * User: ADMIN
 * Date: 19.01.12
 * Time: 15:32
 * To change this template use File | Settings | File Templates.
 */
public class ComparatorFactory {
    public static Comparator getProbationerCodeComparator() {
        return new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                int result = Integer.valueOf(o1.toString().charAt(0)) - Integer.valueOf(o2.toString().charAt(0));
//        if (result != 0) return (int)(result/Math.abs(result));
//        result=Integer.valueOf(o1.toString().substring(1))-Integer.valueOf(o2.toString().substring(1));
//        return (result != 0) ? (int)(result/Math.abs(result)) : 0;

                if (result != 0) return result;
                result = Integer.valueOf(o1.toString().substring(1)) - Integer.valueOf(o2.toString().substring(1));
                return (result != 0) ? result : 0;
            }
        };
    }
}
